package com.stadyhelper.mapper;

import com.stadyhelper.pojo.Result;
import com.stadyhelper.pojo.Score;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ScoreMapper {
    //添加
    @Insert("insert into score (scoreDate, examsMessage, scoreChinese, scoreMath, scoreEnglish, scorePhysics, scoreChemistry, scoreBiologic,scoreTotal ) " +
            "VALUES (#{scoreDate},#{examsMessage},#{scoreChinese},#{scoreMath},#{scoreEnglish},#{scorePhysics},#{scoreChemistry},#{scoreBiologic},#{scoreTotal})")
    void addScore(Score score);
    //列出
    List<Score> listScore(String name);
    //获取最新成绩数据用以分析
    @Select("select * from score order by scoreDate desc limit 1")
    Score selectNewScore();
    //为图表获取数据
    @Select("select examsMessage,scoreTotal from score order by scoreDate limit #{modelNum}")
    List<Score> selectForModel(Integer modelNum);
    //修改成绩数据
    @Update("update score set scoreDate=#{scoreDate}, examsMessage=#{examsMessage}," +
                            " scoreChinese=#{scoreChinese}, scoreMath=#{scoreMath}," +
                            " scoreEnglish=#{scoreEnglish}, scorePhysics=#{scorePhysics}," +
                            " scoreChemistry=#{scoreChemistry},scoreBiologic=#{scoreBiologic}," +
                            "scoreTotal=#{scoreTotal} where id=#{id}")
    void updateScore(Score score);

    //删除成绩
    @Delete("delete from score where id=#{id}")
    void deleteById(Integer id);
}
